home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / Portable Patmos / var / tmp / cc000048.i < prev   
Encoding:
Text File  |  1995-10-25  |  12.3 KB  |  1,455 lines

  1. # 1 "getopt.c"
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39. # 1 "/usr/include/stdio.h" 1 3
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82. # 1 "/usr/include/sys/cdefs.h" 1 3
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147. # 82 "/usr/include/sys/cdefs.h" 3
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177. # 43 "/usr/include/stdio.h" 2 3
  178.  
  179.  
  180. # 1 "/usr/include/machine/ansi.h" 1 3
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239. # 45 "/usr/include/stdio.h" 2 3
  240.  
  241.  
  242. typedef    unsigned int            size_t;
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250. typedef long fpos_t;         
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261. struct __sbuf {
  262.     unsigned char *_base;
  263.     int    _size;
  264. };
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290. typedef    struct __sFILE {
  291.     unsigned char *_p;     
  292.     int    _r;         
  293.     int    _w;         
  294.     short    _flags;         
  295.     short    _file;         
  296.     struct    __sbuf _bf;     
  297.     int    _lbfsize;     
  298.  
  299.      
  300.     void    *_cookie;     
  301.     int    (*_close)  (void *)         ;
  302.     int    (*_read)   (void *, char *, int)         ;
  303.     fpos_t    (*_seek)   (void *, fpos_t, int)         ;
  304.     int    (*_write)  (void *, const char *, int)         ;
  305.  
  306.      
  307.     struct    __sbuf _ub;     
  308.     unsigned char *_up;     
  309.     int    _ur;         
  310.  
  311.      
  312.     unsigned char _ubuf[3];     
  313.     unsigned char _nbuf[1];     
  314.  
  315.      
  316.     struct    __sbuf _lb;     
  317.  
  318.      
  319.     int    _blksize;     
  320.     int    _offset;     
  321. } FILE;
  322.  
  323.  
  324. extern FILE __sF[];
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.      
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392. void     clearerr  (FILE *)         ;
  393. int     fclose  (FILE *)         ;
  394. int     feof  (FILE *)         ;
  395. int     ferror  (FILE *)         ;
  396. int     fflush  (FILE *)         ;
  397. int     fgetc  (FILE *)         ;
  398. int     fgetpos  (FILE *, fpos_t *)         ;
  399. char    *fgets  (char *, size_t, FILE *)         ;
  400. FILE    *fopen  (const char *, const char *)         ;
  401. int     fprintf  (FILE *, const char *, ...)         ;
  402. int     fputc  (int, FILE *)         ;
  403. int     fputs  (const char *, FILE *)         ;
  404. size_t     fread  (void *, size_t, size_t, FILE *)         ;
  405. FILE    *freopen  (const char *, const char *, FILE *)         ;
  406. int     fscanf  (FILE *, const char *, ...)         ;
  407. int     fseek  (FILE *, long, int)         ;
  408. int     fsetpos  (FILE *, const fpos_t *)         ;
  409. long     ftell  (const FILE *)         ;
  410. size_t     fwrite  (const void *, size_t, size_t, FILE *)         ;
  411. int     getc  (FILE *)         ;
  412. int     getchar  (void)         ;
  413. char    *gets  (char *)         ;
  414.  
  415. extern int sys_nerr;             
  416. extern const char *const sys_errlist[];
  417.  
  418. void     perror  (const char *)         ;
  419. int     printf  (const char *, ...)         ;
  420. int     putc  (int, FILE *)         ;
  421. int     putchar  (int)         ;
  422. int     puts  (const char *)         ;
  423. int     remove  (const char *)         ;
  424. int     rename   (const char *, const char *)         ;
  425. void     rewind  (FILE *)         ;
  426. int     scanf  (const char *, ...)         ;
  427. void     setbuf  (FILE *, char *)         ;
  428. int     setvbuf  (FILE *, char *, int, size_t)         ;
  429. int     sprintf  (char *, const char *, ...)         ;
  430. int     sscanf  (const char *, const char *, ...)         ;
  431. FILE    *tmpfile  (void)         ;
  432. char    *tmpnam  (char *)         ;
  433. int     ungetc  (int, FILE *)         ;
  434. int     vfprintf  (FILE *, const char *, char *            )         ;
  435. int     vprintf  (const char *, char *            )         ;
  436. int     vsprintf  (char *, const char *, char *            )         ;
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447. char    *ctermid  (char *)         ;
  448. char    *cuserid  (char *)         ;
  449. FILE    *fdopen  (int, const char *)         ;
  450. int     fileno  (FILE *)         ;
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459. char    *fgetline  (FILE *, size_t *)         ;
  460. int     fpurge  (FILE *)         ;
  461. int     getw  (FILE *)         ;
  462. int     pclose  (FILE *)         ;
  463. FILE    *popen  (const char *, const char *)         ;
  464. int     putw  (int, FILE *)         ;
  465. void     setbuffer  (FILE *, char *, int)         ;
  466. int     setlinebuf  (FILE *)         ;
  467. char    *tempnam  (const char *, const char *)         ;
  468. int     snprintf  (char *, size_t, const char *, ...)         
  469.         __attribute__((format (printf, 3, 4)));
  470. int     vsnprintf  (char *, size_t, const char *, char *            )         
  471.         __attribute__((format (printf, 3, 0)));
  472. int     vscanf  (const char *, char *            )         
  473.         __attribute__((format (scanf, 1, 0)));
  474. int     vsscanf  (const char *, const char *, char *            )         
  475.         __attribute__((format (scanf, 2, 0)));
  476.  
  477.  
  478.  
  479.  
  480.  
  481.  
  482.  
  483.  
  484.  
  485.  
  486.  
  487.  
  488.  
  489. FILE    *funopen  (const void *,
  490.         int (*)(void *, char *, int),
  491.         int (*)(void *, const char *, int),
  492.         fpos_t (*)(void *, fpos_t, int),
  493.         int (*)(void *))         ;
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503. int    __srget  (FILE *)         ;
  504. int    __svfscanf  (FILE *, const char *, char *            )         ;
  505. int    __swbuf  (int, FILE *)         ;
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514. static __inline int __sputc(int _c, FILE *_p) {
  515.     if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))
  516.         return (*_p->_p++ = _c);
  517.     else
  518.         return (__swbuf(_c, _p));
  519. }
  520. # 337 "/usr/include/stdio.h" 3
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543.  
  544. # 38 "getopt.c" 2
  545.  
  546. # 1 "tailor.h" 1
  547.  
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  
  559.  
  560.  
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571. # 65 "tailor.h"
  572.  
  573.  
  574.  
  575.  
  576. # 109 "tailor.h"
  577.  
  578.  
  579. # 130 "tailor.h"
  580.  
  581.  
  582. # 144 "tailor.h"
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592. # 172 "tailor.h"
  593.  
  594.  
  595. # 194 "tailor.h"
  596.  
  597.  
  598. # 215 "tailor.h"
  599.  
  600.  
  601. # 230 "tailor.h"
  602.  
  603.  
  604. # 250 "tailor.h"
  605.  
  606.  
  607.  
  608.  
  609.  
  610.  
  611.  
  612.  
  613.  
  614.  
  615.  
  616.  
  617.  
  618.  
  619.  
  620.      
  621.  
  622.  
  623.  
  624.  
  625.  
  626.  
  627.  
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.     
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.  
  667.  
  668.  
  669.  
  670.  
  671.  
  672.  
  673.  
  674.  
  675.  
  676.  
  677.  
  678.  
  679.  
  680.  
  681.  
  682.  
  683.  
  684. # 39 "getopt.c" 2
  685.  
  686.  
  687.  
  688.  
  689.  
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725. # 1 "getopt.h" 1
  726.  
  727.  
  728.  
  729.  
  730.  
  731.  
  732.  
  733.  
  734.  
  735.  
  736.  
  737.  
  738.  
  739.  
  740.  
  741.  
  742.  
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  
  749.  
  750.  
  751.  
  752.  
  753.  
  754.  
  755.  
  756. extern char *optarg;
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  
  770. extern int optind;
  771.  
  772.  
  773.  
  774.  
  775. extern int opterr;
  776.  
  777.  
  778.  
  779. extern int optopt;
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797.  
  798.  
  799.  
  800.  
  801.  
  802. struct option
  803. {
  804.  
  805.   const char *name;
  806.  
  807.  
  808.  
  809.    
  810.  
  811.   int has_arg;
  812.   int *flag;
  813.   int val;
  814. };
  815.  
  816.  
  817.  
  818.  
  819.  
  820.  
  821.  
  822.  
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829. extern int getopt_long (int argc, char *const *argv, const char *shortopts,
  830.                 const struct option *longopts, int *longind);
  831. extern int getopt_long_only (int argc, char *const *argv,
  832.                  const char *shortopts,
  833.                      const struct option *longopts, int *longind);
  834.  
  835.  
  836. extern int _getopt_internal (int argc, char *const *argv,
  837.                  const char *shortopts,
  838.                      const struct option *longopts, int *longind,
  839.                  int long_only);
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853. # 79 "getopt.c" 2
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862. char *optarg = 0;
  863.  
  864.  
  865.  
  866.  
  867.  
  868.  
  869.  
  870.  
  871.  
  872.  
  873.  
  874.  
  875.  
  876.  
  877. int optind = 0;
  878.  
  879.  
  880.  
  881.  
  882.  
  883.  
  884.  
  885.  
  886. static char *nextchar;
  887.  
  888.  
  889.  
  890.  
  891. int opterr = 1;
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898. int optopt = '\0' ;
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.  
  929. static enum
  930. {
  931.   REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
  932. } ordering;
  933.  
  934. # 167 "getopt.c"
  935.  
  936.  
  937.  
  938.  
  939.  
  940.  
  941. extern char *getenv(const char *name);
  942. extern int  strcmp (const char *s1, const char *s2);
  943. extern int  strncmp(const char *s1, const char *s2, int n);
  944.  
  945. static int my_strlen(const char *s);
  946. static char *my_index (const char *str, int chr);
  947.  
  948.  
  949.  
  950.  
  951. static int
  952. my_strlen (str)
  953.      const char *str;
  954. {
  955.   int n = 0;
  956.   while (*str++)
  957.     n++;
  958.   return n;
  959. }
  960.  
  961. static char *
  962. my_index (str, chr)
  963.      const char *str;
  964.      int chr;
  965. {
  966.   while (*str)
  967.     {
  968.       if (*str == chr)
  969.     return (char *) str;
  970.       str++;
  971.     }
  972.   return 0;
  973. }
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983. static int first_nonopt;
  984. static int last_nonopt;
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.  
  997.  
  998.  
  999.  
  1000.  
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006. static void exchange (char **argv);
  1007.  
  1008.  
  1009. static void
  1010. exchange (argv)
  1011.      char **argv;
  1012. {
  1013.   char *temp, **first, **last;
  1014.  
  1015.    
  1016.   first = &argv[first_nonopt];
  1017.   last  = &argv[optind-1];
  1018.   while (first < last) {
  1019.     temp = *first; *first = *last; *last = temp; first++; last--;
  1020.   }
  1021.    
  1022.   first = &argv[first_nonopt];
  1023.   first_nonopt += (optind - last_nonopt);
  1024.   last  = &argv[first_nonopt - 1];
  1025.   while (first < last) {
  1026.     temp = *first; *first = *last; *last = temp; first++; last--;
  1027.   }
  1028.  
  1029.    
  1030.   first = &argv[first_nonopt];
  1031.   last_nonopt = optind;
  1032.   last  = &argv[last_nonopt-1];
  1033.   while (first < last) {
  1034.     temp = *first; *first = *last; *last = temp; first++; last--;
  1035.   }
  1036. }
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.  
  1064.  
  1065.  
  1066.  
  1067.  
  1068.  
  1069.  
  1070.  
  1071.  
  1072.  
  1073.  
  1074.  
  1075.  
  1076.  
  1077.  
  1078.  
  1079.  
  1080.  
  1081.  
  1082.  
  1083.  
  1084.  
  1085.  
  1086.  
  1087.  
  1088.  
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094. int
  1095. _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
  1096.      int argc;
  1097.      char *const *argv;
  1098.      const char *optstring;
  1099.      const struct option *longopts;
  1100.      int *longind;
  1101.      int long_only;
  1102. {
  1103.   int option_index;
  1104.  
  1105.   optarg = 0;
  1106.  
  1107.    
  1108.  
  1109.  
  1110.  
  1111.  
  1112.   if (optind == 0)
  1113.     {
  1114.       first_nonopt = last_nonopt = optind = 1;
  1115.  
  1116.       nextchar = 0 ;
  1117.  
  1118.        
  1119.  
  1120.       if (optstring[0] == '-')
  1121.     {
  1122.       ordering = RETURN_IN_ORDER;
  1123.       ++optstring;
  1124.     }
  1125.       else if (optstring[0] == '+')
  1126.     {
  1127.       ordering = REQUIRE_ORDER;
  1128.       ++optstring;
  1129.     }
  1130.       else if (getenv ("POSIXLY_CORRECT") != 0 )
  1131.     ordering = REQUIRE_ORDER;
  1132.       else
  1133.     ordering = PERMUTE;
  1134.     }
  1135.  
  1136.   if (nextchar == 0  || *nextchar == '\0')
  1137.     {
  1138.       if (ordering == PERMUTE)
  1139.     {
  1140.        
  1141.  
  1142.  
  1143.       if (first_nonopt != last_nonopt && last_nonopt != optind)
  1144.         exchange ((char **) argv);
  1145.       else if (last_nonopt != optind)
  1146.         first_nonopt = optind;
  1147.  
  1148.        
  1149.  
  1150.  
  1151.       while (optind < argc
  1152.          && (argv[optind][0] != '-' || argv[optind][1] == '\0')
  1153.  
  1154.  
  1155.  
  1156.  
  1157.          )
  1158.         optind++;
  1159.       last_nonopt = optind;
  1160.     }
  1161.  
  1162.        
  1163.  
  1164.  
  1165.  
  1166.  
  1167.       if (optind != argc && !strcmp (argv[optind], "--"))
  1168.     {
  1169.       optind++;
  1170.  
  1171.       if (first_nonopt != last_nonopt && last_nonopt != optind)
  1172.         exchange ((char **) argv);
  1173.       else if (first_nonopt == last_nonopt)
  1174.         first_nonopt = optind;
  1175.       last_nonopt = argc;
  1176.  
  1177.       optind = argc;
  1178.     }
  1179.  
  1180.        
  1181.  
  1182.  
  1183.       if (optind == argc)
  1184.     {
  1185.        
  1186.  
  1187.       if (first_nonopt != last_nonopt)
  1188.         optind = first_nonopt;
  1189.       return (-1) ;
  1190.     }
  1191.  
  1192.        
  1193.  
  1194.  
  1195.       if ((argv[optind][0] != '-' || argv[optind][1] == '\0')
  1196.  
  1197.  
  1198.  
  1199.  
  1200.       )
  1201.     {
  1202.       if (ordering == REQUIRE_ORDER)
  1203.         return (-1) ;
  1204.       optarg = argv[optind++];
  1205.       return 1;
  1206.     }
  1207.  
  1208.        
  1209.  
  1210.  
  1211.       nextchar = (argv[optind] + 1
  1212.           + (longopts != 0  && argv[optind][1] == '-'));
  1213.     }
  1214.  
  1215.   if (longopts != 0 
  1216.       && ((argv[optind][0] == '-'
  1217.        && (argv[optind][1] == '-' || long_only))
  1218.  
  1219.  
  1220.  
  1221.       ))
  1222.     {
  1223.       const struct option *p;
  1224.       char *s = nextchar;
  1225.       int exact = 0;
  1226.       int ambig = 0;
  1227.       const struct option *pfound = 0 ;
  1228.       int indfound = 0;
  1229.  
  1230.       while (*s && *s != '=')
  1231.     s++;
  1232.  
  1233.        
  1234.       for (p = longopts, option_index = 0; p->name;
  1235.        p++, option_index++)
  1236.     if (!strncmp (p->name, nextchar, s - nextchar))
  1237.       {
  1238.         if (s - nextchar == my_strlen (p->name))
  1239.           {
  1240.          
  1241.         pfound = p;
  1242.         indfound = option_index;
  1243.         exact = 1;
  1244.         break;
  1245.           }
  1246.         else if (pfound == 0 )
  1247.           {
  1248.          
  1249.         pfound = p;
  1250.         indfound = option_index;
  1251.           }
  1252.         else
  1253.            
  1254.           ambig = 1;
  1255.       }
  1256.  
  1257.       if (ambig && !exact)
  1258.     {
  1259.       if (opterr)
  1260.         fprintf ((&__sF[2]) , "%s: option `%s' is ambiguous\n",
  1261.              argv[0], argv[optind]);
  1262.       nextchar += my_strlen (nextchar);
  1263.       optind++;
  1264.       return '\0' ;
  1265.     }
  1266.  
  1267.       if (pfound != 0 )
  1268.     {
  1269.       option_index = indfound;
  1270.       optind++;
  1271.       if (*s)
  1272.         {
  1273.            
  1274.  
  1275.           if (pfound->has_arg)
  1276.         optarg = s + 1;
  1277.           else
  1278.         {
  1279.           if (opterr)
  1280.             {
  1281.               if (argv[optind - 1][1] == '-')
  1282.              
  1283.             fprintf ((&__sF[2]) ,
  1284.                  "%s: option `--%s' doesn't allow an argument\n",
  1285.                  argv[0], pfound->name);
  1286.               else
  1287.              
  1288.             fprintf ((&__sF[2]) ,
  1289.                  "%s: option `%c%s' doesn't allow an argument\n",
  1290.                  argv[0], argv[optind - 1][0], pfound->name);
  1291.             }
  1292.           nextchar += my_strlen (nextchar);
  1293.           return '\0' ;
  1294.         }
  1295.         }
  1296.       else if (pfound->has_arg == 1)
  1297.         {
  1298.           if (optind < argc)
  1299.         optarg = argv[optind++];
  1300.           else
  1301.         {
  1302.           if (opterr)
  1303.             fprintf ((&__sF[2]) , "%s: option `%s' requires an argument\n",
  1304.                  argv[0], argv[optind - 1]);
  1305.           nextchar += my_strlen (nextchar);
  1306.           return optstring[0] == ':' ? ':' : '\0' ;
  1307.         }
  1308.         }
  1309.       nextchar += my_strlen (nextchar);
  1310.       if (longind != 0 )
  1311.         *longind = option_index;
  1312.       if (pfound->flag)
  1313.         {
  1314.           *(pfound->flag) = pfound->val;
  1315.           return 0;
  1316.         }
  1317.       return pfound->val;
  1318.     }
  1319.        
  1320.  
  1321.  
  1322.  
  1323.       if (!long_only || argv[optind][1] == '-'
  1324.  
  1325.  
  1326.  
  1327.       || my_index (optstring, *nextchar) == 0 )
  1328.     {
  1329.       if (opterr)
  1330.         {
  1331.           if (argv[optind][1] == '-')
  1332.          
  1333.         fprintf ((&__sF[2]) , "%s: unrecognized option `--%s'\n",
  1334.              argv[0], nextchar);
  1335.           else
  1336.          
  1337.         fprintf ((&__sF[2]) , "%s: unrecognized option `%c%s'\n",
  1338.              argv[0], argv[optind][0], nextchar);
  1339.         }
  1340.       nextchar = (char *) "";
  1341.       optind++;
  1342.       return '\0' ;
  1343.     }
  1344.     }
  1345.  
  1346.    
  1347.  
  1348.   {
  1349.     char c = *nextchar++;
  1350.     char *temp = my_index (optstring, c);
  1351.  
  1352.      
  1353.     if (*nextchar == '\0')
  1354.       ++optind;
  1355.  
  1356.     if (temp == 0  || c == ':')
  1357.       {
  1358.     if (opterr)
  1359.       {
  1360.  
  1361.  
  1362.  
  1363.  
  1364.  
  1365.  
  1366.  
  1367.          
  1368.         fprintf ((&__sF[2]) , "%s: illegal option -- %c\n", argv[0], c);
  1369.  
  1370.       }
  1371.     optopt = c;
  1372.     return '\0' ;
  1373.       }
  1374.     if (temp[1] == ':')
  1375.       {
  1376.     if (temp[2] == ':')
  1377.       {
  1378.          
  1379.         if (*nextchar != '\0')
  1380.           {
  1381.         optarg = nextchar;
  1382.         optind++;
  1383.           }
  1384.         else
  1385.           optarg = 0;
  1386.         nextchar = 0 ;
  1387.       }
  1388.     else
  1389.       {
  1390.          
  1391.         if (*nextchar != '\0')
  1392.           {
  1393.         optarg = nextchar;
  1394.          
  1395.  
  1396.         optind++;
  1397.           }
  1398.         else if (optind == argc)
  1399.           {
  1400.         if (opterr)
  1401.           {
  1402.  
  1403.  
  1404.  
  1405.  
  1406.              
  1407.             fprintf ((&__sF[2]) , "%s: option requires an argument -- %c\n",
  1408.                  argv[0], c);
  1409.  
  1410.           }
  1411.         optopt = c;
  1412.         if (optstring[0] == ':')
  1413.           c = ':';
  1414.         else
  1415.           c = '\0' ;
  1416.           }
  1417.         else
  1418.            
  1419.  
  1420.           optarg = argv[optind++];
  1421.         nextchar = 0 ;
  1422.       }
  1423.       }
  1424.     return c;
  1425.   }
  1426. }
  1427.  
  1428. int
  1429. getopt (argc, argv, optstring)
  1430.      int argc;
  1431.      char *const *argv;
  1432.      const char *optstring;
  1433. {
  1434.   return _getopt_internal (argc, argv, optstring,
  1435.                (const struct option *) 0,
  1436.                (int *) 0,
  1437.                0);
  1438. }
  1439.  
  1440. int
  1441. getopt_long (argc, argv, options, long_options, opt_index)
  1442.      int argc;
  1443.      char *const *argv;
  1444.      const char *options;
  1445.      const struct option *long_options;
  1446.      int *opt_index;
  1447. {
  1448.   return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
  1449. }
  1450.  
  1451.  
  1452.  
  1453. # 755 "getopt.c"
  1454.  
  1455.